// 使用指定配置创建 logger 。

package main

import "gitee.com/baihr/iam/pkg/log"

func main() {
	defer log.Flush()

	opts := &log.Options{
		Level:             "debug",
		Format:            "console",
		EnableColor:       true,
		DisableCaller:     false,
		DisableStacktrace: false,
		OutputPaths:       []string{"stdout", "stdout.log"},
		ErrorOutputPaths:  []string{"stderr"},
		Development:       false,
	}

	// 使用指定配置创建 logger ，覆盖使用默认配置的 logger 。
	log.Init(opts)

	// 打印 debug 日志。
	log.Debug("this is a debug message")
	// 打印 info 日志。
	log.Info("this is an info message")
	// 产生错误日志。
	log.Infow("non-string key", 0, 1)
}

// output:
// 2024-01-19 16:24:57.690 DEBUG   configure/main.go:25    this is a debug message
// 2024-01-19 16:24:57.691 INFO    configure/main.go:27    this is an info message
// 2024-01-19 16:24:57.691 ERROR   log/log.go:164  Ignored key-value pairs with non-string keys.   {"invalid": [{"position": 0, "key": 0, "value": 1}]}
// gitee.com/baihr/iam/pkg/log.Infow
//         /home/ian/workspace/golang/src/gitee.com/baihr/iam/pkg/log/log.go:164
// main.main
//         /home/ian/workspace/golang/src/gitee.com/baihr/iam/pkg/log/example/configure/main.go:29
// runtime.main
//         /usr/local/go/src/runtime/proc.go:250
// 2024-01-19 16:24:57.691 INFO    configure/main.go:29    non-string key
